import paramiko
import time


twrssh = paramiko.SSHClient()
twrssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
twrssh.connect('', port=22, username='', password='')
remote = twrssh.invoke_shell()
remote.send('enable\n')
remote.send('\n')
time.sleep(1)
# print(remote.recv(1000).decode('utf-8'))
# time.sleep(1)


def command(cmd):
    remote.send(cmd + '\n')
    time.sleep(1)

    while True:
        buffer = remote.recv(2000).decode('utf-8')
        print(buffer)
        if '--More--' in buffer:
            remote.send(' ')
            time.sleep(1)
        elif buffer.endswith('>') or buffer.endswith('#'):
            break


command('show cpu')
twrssh.close()
